import java.io.IOException;
import java.util.Scanner;
import java.util.Random;

public class against extends Hero {
    public static int hitRatio(){
        Random r=new Random();
        int a=r.nextInt(100);
        int b;
        if(a<=80){
            b=1;
        }else{
            b=0;
        }
        return b;
    }
    public static boolean fallInBattle(int life){
        if(life<=0){
            System.out.println("You're dead, the game is over");
            return false;
        }else{
            return true;
        }
    }
    public static void cls() throws IOException, InterruptedException{

        new ProcessBuilder("cmd", "/c", "cls")

                .inheritIO()

                .start()

                .waitFor();

    }

    public static void main(String[] args) throws InterruptedException, IOException {
        System.out.println("请玩家选择角色\n1:刺客    2:法师    3:坦克");
        Scanner s1=new Scanner(System.in);
        String a;
        a=s1.nextLine();
        Scanner s2=new Scanner(System.in);
        String b;
        b=s2.nextLine();
        String c=a+b;
        switch(c){

            case "12":

                System.out.println("刺客VS法师");
                Assassin Assassin1=new Assassin();
                Mage Mage1=new Mage();
                for(int i=1;i<=50;i++){
                    int d=hitRatio();
                    Thread.currentThread().sleep(1000 * 2);
                    cls();
                    System.out.println("第"+(i+1)/2+"回合:\n玩家1的生命值为："+Assassin1.life+"  攻击力为："+Assassin1.damagel+"  防御力为："+Assassin1.defence+"\n玩家2的生命值为："+Mage1.life+"  攻击力为："+Mage1.damagel+"  防御力为："+Mage1.defence);
                    boolean p1=fallInBattle(Assassin1.life);
                    boolean p2=fallInBattle(Mage1.life);
                    if((i%2)==0){
                        if(p1&&p2){
                            System.out.println("请玩家2选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Assassin1.life,Mage1.damagel,Assassin1.defence);
                                        Assassin1.life=Assassin1.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Mage1.damagel=Mage.criticalStrike(Mage1.damagel);
                                    System.out.println("攻击力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }else{
                        if(p1&&p2){
                            System.out.println("请玩家1选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Mage1.life,Assassin1.damagel,Mage1.defence);
                                        Mage1.life=Mage1.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Assassin1.defence=Assassin.shield(Assassin1.defence);
                                    System.out.println("防御力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }
                }
                break;
            case "13":

                System.out.println("刺客VS坦克");
                Assassin Assassin2=new Assassin();
                Tanke Tanke1=new Tanke();
                for(int i=1;i<=50;i++){
                    int d=hitRatio();
                    Thread.currentThread().sleep(1000 * 2);
                    cls();
                    System.out.println("第"+(i+1)/2+"回合:\n玩家1的生命值为："+Assassin2.life+"  攻击力为："+Assassin2.damagel+"  防御力为："+Assassin2.defence+"\n玩家2的生命值为："+Tanke1.life+"  攻击力为："+Tanke1.damagel+"  防御力为："+Tanke1.defence);
                    boolean p1=fallInBattle(Assassin2.life);
                    boolean p2=fallInBattle(Tanke1.life);
                    if((i%2)==0){
                        if(p1&&p2){
                            System.out.println("请玩家2选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Assassin2.life,Tanke1.damagel,Assassin2.defence);
                                        Assassin2.life=Assassin2.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Tanke1.life=Tanke.returnedBlood(Tanke1.life);
                                    System.out.println("加血");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }else{
                        if(p1&&p2){
                            System.out.println("请玩家1选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Tanke1.life,Assassin2.damagel,Tanke1.defence);
                                        Tanke1.life=Tanke1.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Assassin2.defence=Assassin.shield(Assassin2.defence);
                                    System.out.println("防御力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }
                }
                break;
            case "21":

                System.out.println("法师VS刺客");
                Mage Mage2=new Mage();
                Assassin Assassin3=new Assassin();
                for(int i=1;i<=50;i++){
                    int d=hitRatio();
                    Thread.currentThread().sleep(1000 * 2);
                    cls();
                    System.out.println("第"+(i+1)/2+"回合:\n玩家1的生命值为："+Mage2.life+"  攻击力为："+Mage2.damagel+"  防御力为："+Mage2.defence+"\n玩家2的生命值为："+Assassin3.life+"  攻击力为："+Assassin3.damagel+"  防御力为："+Assassin3.defence);
                    boolean p1=fallInBattle(Mage2.life);
                    boolean p2=fallInBattle(Assassin3.life);
                    if((i%2)==0){
                        if(p1&&p2){
                            System.out.println("请玩家2选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Mage2.life,Assassin3.damagel,Mage2.defence);
                                        Mage2.life=Mage2.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Assassin3.defence=Assassin.shield(Assassin3.defence);
                                    System.out.println("防御力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }else{
                        if(p1&&p2){
                            System.out.println("请玩家1选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Assassin3.life,Mage2.damagel,Assassin3.defence);
                                        Assassin3.life=Assassin3.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Mage2.damagel=Mage.criticalStrike(Mage2.damagel);
                                    System.out.println("攻击力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }
                }
                break;

            case "23":

                System.out.println("法师VS坦克");
                Mage Mage3=new Mage();
                Tanke Tanke2=new Tanke();
                for(int i=1;i<=50;i++){
                    int d=hitRatio();
                    Thread.currentThread().sleep(1000 * 2);
                    cls();
                    System.out.println("第"+(i+1)/2+"回合:\n玩家1的生命值为："+Mage3.life+"  攻击力为："+Mage3.damagel+"  防御力为："+Mage3.defence+"\n玩家2的生命值为："+Tanke2.life+"  攻击力为："+Tanke2.damagel+"  防御力为："+Tanke2.defence);
                    boolean p1=fallInBattle(Mage3.life);
                    boolean p2=fallInBattle(Tanke2.life);
                    if((i%2)==0){
                        if(p1&&p2){
                            System.out.println("请玩家2选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Mage3.life,Tanke2.damagel,Mage3.defence);
                                        Mage3.life=Mage3.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Tanke2.life=Tanke.returnedBlood(Tanke2.life);
                                    System.out.println("加血");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }else{
                        if(p1&&p2){
                            System.out.println("请玩家1选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Tanke2.life,Mage3.damagel,Tanke2.defence);
                                        Tanke2.life=Tanke2.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Mage3.damagel=Mage.criticalStrike(Mage3.damagel);
                                    System.out.println("攻击力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }
                }
                break;
            case "31":

                System.out.println("坦克VS刺客");
                Tanke Tanke3=new Tanke();
                Assassin Assassin4=new Assassin();
                for(int i=1;i<=50;i++){
                    int d=hitRatio();
                    Thread.currentThread().sleep(1000 * 2);
                    cls();
                    System.out.println("第"+(i+1)/2+"回合:\n玩家1的生命值为："+Tanke3.life+"  攻击力为："+Tanke3.damagel+"  防御力为："+Tanke3.defence+"\n玩家2的生命值为："+Assassin4.life+"  攻击力为："+Assassin4.damagel+"  防御力为："+Assassin4.defence);
                    boolean p1=fallInBattle(Tanke3.life);
                    boolean p2=fallInBattle(Assassin4.life);
                    if((i%2)==0){
                        if(p1&&p2){
                            System.out.println("请玩家2选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Tanke3.life,Assassin4.damagel,Tanke3.defence);
                                        Tanke3.life=Tanke3.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Assassin4.defence=Assassin.shield(Assassin4.defence);
                                    System.out.println("防御力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }else{
                        if(p1&&p2){
                            System.out.println("请玩家1选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Assassin4.life,Tanke3.damagel,Assassin4.defence);
                                        Assassin4.life=Assassin4.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Tanke3.life=Tanke.returnedBlood(Tanke3.life);
                                    System.out.println("加血");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }
                }
                break;
            case "32":

                System.out.println("坦克VS法师");
                Tanke Tanke4=new Tanke();
                Mage Mage4=new Mage();
                for(int i=1;i<=50;i++){
                    int d=hitRatio();
                    Thread.currentThread().sleep(1000 * 2);
                    cls();
                    System.out.println("第"+(i+1)/2+"回合:\n玩家1的生命值为："+Tanke4.life+"  攻击力为："+Tanke4.damagel+"  防御力为："+Tanke4.defence+"\n玩家2的生命值为："+Mage4.life+"  攻击力为："+Mage4.damagel+"  防御力为："+Mage4.defence);
                    boolean p1=fallInBattle(Tanke4.life);
                    boolean p2=fallInBattle(Mage4.life);
                    if((i%2)==0){
                        if(p1&&p2){
                            System.out.println("请玩家2选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){


                                        int damageValues= beAttacked(Tanke4.life,Mage4.damagel,Tanke4.defence);
                                        Tanke4.life=Tanke4.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Mage4.damagel=Mage.criticalStrike(Mage4.damagel);
                                    System.out.println("攻击力增加");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }else{
                        if(p1&&p2){
                            System.out.println("请玩家1选择：a、普通攻击   b、释放技能   c、跳过本回合");
                            Scanner k1=new Scanner(System.in);
                            String k11=k1.nextLine();
                            switch(k11){
                                case "a":
                                    if(d==1){
                                        int damageValues= beAttacked(Mage4.life,Tanke4.damagel,Mage4.defence);
                                        Mage4.life=Mage4.life - damageValues;
                                    }else{
                                        System.out.println("未命中目标");
                                    }
                                    break;
                                case "b":
                                    Tanke4.life=Tanke.returnedBlood(Tanke4.life);
                                    System.out.println("加血");
                                    break;
                                case "c":
                                    break;
                            }
                        }else{
                            if(p1){
                                System.out.println("玩家2阵亡");
                                break;
                            }else{
                                System.out.println("玩家1阵亡");
                                break;
                            }
                        }
                    }
                }
                break;

        }


    }
}
